home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5115 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Where Can I Find Standard C Library S
  5. Date: Fri, 09 Feb 1996 01:30:10 GMT
  6. Organization: Netcom
  7. Message-ID: <311aa327.89794367@nntp.ix.netcom.com>
  8. References: <4fb8mf$ouo@spanky.pls.ov.com> <4fb90l$ouo@spanky.pls.ov.com> <3119E6D9.60FD@cmt.lpr.mail.carel.fi>
  9. NNTP-Posting-Host: ix-dc19-08.ix.netcom.com
  10. X-NETCOM-Date: Thu Feb 08  5:29:49 PM PST 1996
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. Ari Lukumies <aril@cmt.lpr.mail.carel.fi> wrote:
  14.  
  15. > Fletcher.Glenn@ov.com wrote:
  16. > > 
  17. > > 
  18. > > Whoops! for strcpy:
  19. > > 
  20. > > char *strcpy(char *destination, char *source)
  21. > > {
  22. > >     char *retval;
  23. > > 
  24. > >     retval = destination;
  25. > >     while((*destination++ = *source++) != '\0');
  26. > >     return(retval);
  27. > > }
  28. > >                         Fletcher.Glenn@ov.com
  29. > ... And you wonder why printf("%s\n", strcpy(tmp, "thingyam")); may not give correct 
  30. > results using your strcpy version... Try this for size:
  31. >     char *strcpy(char *destination, char *source)
  32. >     {
  33. >         char *retval = destination;
  34. >         do
  35. >             *destination = *source++;
  36. >         while (*destination++ != '\0');
  37. >         return retval;
  38. >     }
  39. > This will also copy the nul-terminator. :)
  40.  
  41. Am I missing something here?  What's wrong with Fletcher's code?  Why
  42. the comment about the nul-terminator?  Fletcher's code also copies it.
  43.  
  44.  
  45. Michael M Rubenstein
  46.